package com.itheima01.day04;

import java.util.Scanner;

/*需求：已知一个数组 arr = {19, 28, 37, 46, 50}; 键盘录入一个数据，查找该数据在数组中的索引，并在控
        制台输出找到的索引值。
*/
public class ArrayTest04 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] arr = {19, 28, 37, 46, 50, 99, 66};
        System.out.println("请输入一个整数:");
        System.out.println();
        int a = 0;
        int num = sc.nextInt();
        for (int i = 0; i < arr.length; i++) {
            if (num == arr[i]) {
                System.out.println("索引值为:" + i);
                break;
            }
            a++;
        }
        if (a >= arr.length) {
            System.out.println("数组中无该数据");
        }
    }
}
